var monprd={};
monprd.currentObj;
monprd.loadList=function (pageNo,isfirst){
	var queryStr=$("#monPrd_queryText").val();
	$('#monPrdTable').empty();
	var params = {pageSize:3,pageNo:pageNo,queryStr:queryStr};
	var config={columns:[{
		headerText:'井名',
		name:'wellName'
	},{
		headerText:'日期',
		name:'date'
	},{
		headerText:'生产量（方）',
		name:'preduction'
	},{
		headerText:'硫酸钠固体含量（千克）',
		name:'na2so4Total'
	},{
		headerText:'氯化钠固体含量（千克）',
		name:'naclTotal'
	},{
		headerText:'统计人',
		name:'operator'
	},{
		headerText:'审核人',
		name:'auditer'
	},{
		headerText:'注采方式',
		name:'produceMethod'
	},{
		headerText:'录入时间',
		name:'dateInput'
	},{
		headerText:'录入人',
		name:'owner'
	},{
		headerText:'操作',
		name:'',
		renderer:function(str) {
		return '<input type="button" onclick="monprd.openDetailDialog('+this.id+')" value="查看">'+
		'<input type="button" onclick="monprd.openUpdateDialog('+this.id+')" value="修改">'+
		'<input type="button" onclick="monprd.doDelete('+this.id+')" value="删除">';
	} 
	}
	],url:basePath+'app/monPrd/loadList',params:params};
	$('#monPrdTable').table(config,true,isfirst);
}
//新增操作
monprd.openAddDialog=function (){
	monprd.cleanAddDialog();
	$("#addMonPrdDialog").dialog({ modal: true ,width: 800});
}
monprd.cleanAddDialog=function (){
	document.getElementById("report_add_form").reset();
	$("#addMonPrd_date").datepicker();
	$.post(basePath+'app/monPrd/getWellList', {}, function(data) {
		var l=$("#addMonPrd_wellTeamId");
		l.empty();
		for(var i in data){
			$("<option value='"+data[i].id+"'>"+data[i].name+"</option>").appendTo(l);
		}
	});
}
monprd.callback=function (){
	try{
		$("#addMonPrdDialog").dialog("close");
	}catch(error){
	}
	try{
		$("#updateMonPrdDialog").dialog("close");
	}catch(error){
	}
}
//查看操作
monprd.openDetailDialog=function (wellId){
	monprd.refreshDetailDialog(wellId);
	$("#detailMonPrdDialog").dialog({ modal: false ,width: 800});
}
monprd.refreshDetailDialog=function (wellId){
	var wg;
	for(var i in window.gridcache){
		if(wellId==window.gridcache[i].id){
			wg=window.gridcache[i];
			break;
		}
	}
	$("#detailMonPrd_wellTeamId").val(wg.wellName);
	$("#detailMonPrd_date").val(wg.date);
	$("#detailMonPrd_waterIn").val(wg.waterIn);
	$("#detailMonPrd_preduction").val(wg.preduction);
	$("#detailMonPrd_oilIn").val(wg.oilIn);
	$("#detailMonPrd_na2so4PerL").val(wg.na2so4PerL);
	$("#detailMonPrd_naclPerL").val(wg.naclPerL);
	$("#detailMonPrd_naclWaterPerL").val(wg.naclWaterPerL);
	$("#detailMonPrd_na2so4Total").val(wg.na2so4Total);
	$("#detailMonPrd_naclTotal").val(wg.naclTotal);
	$("#detailMonPrd_naclTotalNoWater").val(wg.naclTotalNoWater);
	$("#detailMonPrd_pipePressureIn").val(wg.pipePressureIn);
	$("#detailMonPrd_pressureBack").val(wg.pressureBack);
	$("#detailMonPrd_waterTemperature").val(wg.waterTemperature);
	$("#detailMonPrd_na2so4Temperature").val(wg.na2so4Temperature);
	$("#detailMonPrd_operator").val(wg.operator);
	$("#detailMonPrd_auditer").val(wg.auditer);
	$("#detailMonPrd_remark").val(wg.remark);
	$("#detailMonPrd_produceMethod").val(wg.produceMethod);
	$("#detailMonPrd_owner").text(wg.owner);
	$("#detailMonPrd_dateInput").text(wg.dateInput);
}
//修改操作
monprd.openUpdateDialog=function (wellId){
	monprd.refreshUpdateDialog(wellId);
	$("#updateMonPrdDialog").dialog({ modal: true ,width: 800});
}
monprd.refreshUpdateDialog=function (wellId){
	var wg;
	for(var i in window.gridcache){
		if(wellId==window.gridcache[i].id){
			wg=window.gridcache[i];
			break;
		}
	}
	monprd.currentObj=wg;
	$("#updateMonPrd_id").val(wg.id);
	$("#updateMonPrd_date").datepicker();
	$("#updateMonPrd_date").val(wg.date);
	$.post(basePath+'app/monPrd/getWellList', {}, function(data) {
		var l=$("#updateMonPrd_wellTeamId");
		l.empty();
		for(var i in data){
			$("<option value='"+data[i].id+"' "+(wg.wellId==data[i].id?"selected='selected'":"")+">"+data[i].name+"</option>").appendTo(l);
		}
	});
	$("#updateMonPrd_waterIn").val(wg.waterIn);
	$("#updateMonPrd_preduction").val(wg.preduction);
	$("#updateMonPrd_oilIn").val(wg.oilIn);
	$("#updateMonPrd_na2so4PerL").val(wg.na2so4PerL);
	$("#updateMonPrd_naclPerL").val(wg.naclPerL);
	$("#updateMonPrd_naclWaterPerL").val(wg.naclWaterPerL);
	$("#updateMonPrd_na2so4Total").val(wg.na2so4Total);
	$("#updateMonPrd_naclTotal").val(wg.naclTotal);
	$("#updateMonPrd_naclTotalNoWater").val(wg.naclTotalNoWater);
	$("#updateMonPrd_pipePressureIn").val(wg.pipePressureIn);
	$("#updateMonPrd_pressureBack").val(wg.pressureBack);
	$("#updateMonPrd_waterTemperature").val(wg.waterTemperature);
	$("#updateMonPrd_na2so4Temperature").val(wg.na2so4Temperature);
	$("#updateMonPrd_operator").val(wg.operator);
	$("#updateMonPrd_auditer").val(wg.auditer);
	$("#updateMonPrd_remark").val(wg.remark);
	$("#updateMonPrd_produceMethod").val(wg.produceMethod);
	$("#updateMonPrd_owner").text(wg.owner);
	$("#updateMonPrd_dateInput").text(wg.dateInput);
}
//删除操作
monprd.doDelete=function (wellId){
	var i=window.confirm("确认删除？");
	if(i==true){
		$.post(basePath+"app/monPrd/doDeleteMonPrd", {recordId:wellId}, function(data) {
			monprd.loadList();//修改刷新为当前页
		});
	}
}
//导出excel
monprd.exportExcel=function (){
	var qs=$("#monPrd_queryText").val();
	window.open(basePath+"app/monPrd/exportExcel?queryStr="+qs);
}
$(function() {
	currentModule=monprd;//当前模块
	monprd.loadList(1,true);
	$("#reportQuery").bind("keyup",function (event){
		if (event.keyCode=="13"){
			monprd.loadList(1);
		}
	});
});